$(function() {
	//初始化
	Begin();
})
Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};
function dateFormat(d) {
    var date = new Date(d);
    return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
}

var selectOptions = [
				{value:'1',lebal:'test1'},
				{value:'2',lebal:'test2'}
			];

var table = new VanyTable({
	el: "#table",
	url: "/system/operateLogs/queryLogsList",
	methodTypes:"GET",  //数据获取方式
	index: true, //选框
	selection: false, //编号
	pages: true, //是否需要分页，与scrollPage最好二选一
	pageSize: 10,
	pageSizes: [10,20,30],
	scrollPage: false, //是否滚动分页，与pages最好二选一
	//height: 200,  //固定高度，滚动分页时需要使用
	// right、topRight、bottomLeft
	btnPostion: "bottomLeft", //底部菜单所在位置
	btnNotes: "", //按钮旁边是否需要文字
	btns: [], //底部菜单
	zidingyiBtn: '', //底部菜单自定义
	zidingyiTop: '<el-form ref="form" :model="form" label-width="80px" class="btnright">' +
		'<el-row :gutter="20">' +
		'<el-col :span="24">' +
		'<el-form-item label="操作时间:"><el-date-picker type="datetimerange" v-model="form.Timevalue" placeholder="选择时间范围" :picker-options="pickerOptions2"></el-time-picker></el-form-item>' +
		'<el-form-item label="账号:"><el-input @keyup.enter.native="search" :on-icon-click="search" v-model="form.searchValue" placeholder="请输入您要搜索的账号" icon="search"></el-input></el-form-item>' +
		//'<el-form-item label="类别:"><el-select v-model="form.value1" placeholder="请选择"></el-select></el-form-item>'+
		//<el-option v-for="item in selectOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
		'<el-button @click="search">搜索</el-button><el-button @click="exportExl">导出</el-button>' +
		'</el-col>' +
		'</el-row>' +
		'</el-form>', //头部按钮自定义，v-model中可以写form.value1到form.value8
	keys: [{
		"key": "userId",
		"name": "登录账号"
	},{
		"key": "userName",
		"name": "操作用户"
	}, {
		"key": "accessTime",
		"name": "操作时间",
		"zidingyi": ":formatter=\"dateFormat\" ",
	}, {
		"key": "rspMsg",
		"name": "操作结果"
	}, {
		"key": "loginIp",
		"name": "IP"
	}, {
		"key": "apiId",
		"name": "接口"
	}, {
		"key": "operationContent",
		"name": "内容"
	}] //表格title
});

table.on("rowClick", function(index, row, event, column) {
	if(column.type === "selection" || column.property === "status") {
		return false;
	}
	console.log("有一行被单击了");
});

table.on("selectionChange", function(selection) {
	console.log("有一行被选中啦");
});

table.on("exportExl", function(selection) {
	var Timevalue = table.form.Timevalue;
	if(Timevalue&&Timevalue instanceof Array&&Timevalue.length==2){
		if(Timevalue[0]!=null&&Timevalue[1]!=null){
			var sTime = dateFormat(Timevalue[0].toString());
	    	var eTime = dateFormat(Timevalue[1].toString());
	    	Timevalue = sTime + ";" + eTime;
		}
    }
	var searchValue = table.form.searchValue;
	
	
	var self = this;
	self.$confirm('确认导出?', '提示', {
		confirmButtonText: '确定',
		cancelButtonText: '取消',
		type: 'warning',
		customClass: "notLoadingThis"
	}).then(function() {
		location.href = "/system/operateLogs/exportLogsList?token=" + sessionStorage.token + "&Timevalue=" +Timevalue + "&searchValue=" +searchValue;
	}).catch(function() {})
	/**
	var params = {
			Timevalue:Timevalue,
			searchValue:searchValue
	};
	VanyAjax("/system/operateLogs/exportLogsList", params).done(function(data) {
		
	}, true, self);
	**/
});

table.on("search", function(selection) {
	var Timevalue = table.form.Timevalue;
	if(Timevalue&&Timevalue instanceof Array&&Timevalue.length==2){
		if(Timevalue[0]!=null&&Timevalue[1]!=null){
			var sTime = dateFormat(Timevalue[0].toString());
	    	var eTime = dateFormat(Timevalue[1].toString());
	    	Timevalue = sTime + ";" + eTime;
		}
    }
	var searchValue = table.form.searchValue;
	
	table.getData({
		Timevalue: Timevalue,
		searchValue: searchValue
	}, true);
	
});


table.getData({
	orgCode: "000000",
	searchValue: "",
	status: ""
}, true);

//初始化
function Begin() {
	//面包屑
	new Vue().$mount('#crumbs');
	sessionStorage.Jurisdiction = "base_tag_addBaseRootTag,base_team_delTeamUsesr,base_user_update,base_tag_modifyBaseTag,base_team_modify,base_role_modifyRFAAndRemove,base_tagUser_export,base_customerUser_export,base_role_modifyRoleInfo,base_customer_import,base_org_delete,base_customer_addTag,base_team_delete,base_org_export,base_role_modifyRoleUser,base_user_resetUserStatus,base_org_import,base_user_export,base_tag_modifyTag,base_customer_add,base_customer_modifyTag,base_user_resetUserPassword,base_user_import,base_team_addTeamUsers,base_tag_deleteTag,base_user_deleteUsers,base_org_update,base_role_deleteRoleUser,base_user_moveUsers,base_teamUser_export,base_tag_addBaseTag,base_team_add,base_tag_selectTagUser,base_tag_addTag,base_customer_delCustomer,base_customer_addRootTag,base_tag_addRootTag,base_org_add,base_user_updateOrderNum,base_tag_deleteTagUser,base_tag_deleteBaseTag,base_customer_deleteTag,base_org_updateOrderNum,base_user_add"
}